package com.shenbianyun.bosskgpay.service.sign;

import com.alibaba.fastjson.JSONObject;
import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
import org.apache.jmeter.samplers.SampleResult;

/**
 * @Author yvan
 * @Date 2021/11/2 16:38:30
 * @Description Jmeter 自由职业者签约查询 请求
 **/

public class TestUserSignQueryServiceJ extends AbstractJavaSamplerClient {


    @Override
    public SampleResult runTest(JavaSamplerContext javaSamplerContext) {
        SampleResult sampleResult = new SampleResult();
        String resData = "";
        TestUserSignQueryServiceD usq = null;

        try {
            sampleResult.sampleStart();
            if (usq == null) {
                usq = new TestUserSignQueryServiceD();
            }
            resData = usq.runTestUserSignQueryService();

            //断言
            JSONObject jsonObject1 = JSONObject.parseObject(resData);
            if (jsonObject1.get("resCode").equals("0000")) {
                sampleResult.setResponseOK();
                sampleResult.setResponseData(true+"", SampleResult.TEXT);
                System.out.println("签约查询结果:" + true);
            } else {
                sampleResult.setSuccessful(false);
                sampleResult.setResponseData(false + " " + jsonObject1.get("resMsg"), SampleResult.TEXT);
                System.out.println("签约查询结果:" + false + " " + jsonObject1.get("resMsg"));
            }
        } catch (Exception e) {
            sampleResult.setSuccessful(false);
            sampleResult.setResponseData(resData, SampleResult.TEXT);
            sampleResult.setResponseMessage(e.toString());

        } finally {
            sampleResult.sampleEnd();
        }
        return sampleResult;
    }



}
